/**
 *  定位文件工具类
 */

/**
 * 小程序进入前台接收位置
 * @param {*} type 坐标类型 wgs84 || gcj02
 */
export function getUserStartLocationUpdate(type = 'wgs84') {
  return new Promise((resolve, reject) => {
    wx.startLocationUpdate({
      type: type,
      success: (res) => {
        resolve(res);
      },
      fail: err => {
        reject(err);
      }
    })
  })
}


/**
 * onLocationChangeError
 */
export function watchUserLocationErr() {
  return new Promise((resolve, reject) => {
    wx.onLocationChangeError((err) => {
      resolve(err);
    })
  })
}
/**
 * 取消监听用户位置
 */
export function stopWatchLocation() {
  return new Promise((resolve, reject) => {
    wx.stopLocationUpdate({
      success: res => {
        resolve(res);
      },
      fail: err => {
        reject(err);
      }
    });
  })
}